﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;

namespace SharePointOptimizer.PL.WPF
{

    public class IssueServer
    {
        public IssueServer()
        {
            Instances = new ObservableCollection<IssueInstance>();
            Categories = new ObservableCollection<IssueCategory>();
        }

        public String Name { get; set; }
        public ObservableCollection<IssueInstance> Instances { get; set; }
        public ObservableCollection<IssueCategory> Categories { get; set; }


        public int TotalNumberOfIssues()
        {
            int numberOfIssue = 0;


            foreach (var cat in Categories)
            {
                numberOfIssue += cat.Issues.Count;
            }

            foreach (var inst in Instances)
            {
                numberOfIssue += inst.TotalNumberOfIssues();
            }

            return numberOfIssue;
        }

        public override string ToString()
       {
           return "Server: " + this.Name + " (" + TotalNumberOfIssues().ToString() + " issues)";
       }

    }
}
